package top.loveeveryone.configPage.Controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import top.loveeveryone.configPage.param.ConfigFileReq;
import top.loveeveryone.configPage.param.Result;
import top.loveeveryone.configPage.service.ConfigFilePage;

import javax.annotation.Resource;

@RequestMapping("monitorDaily")
@RestController
public class ConfigFilePageController {
    private static final Logger log = LoggerFactory.getLogger(ConfigFilePageController.class);

    @Resource
    private ConfigFilePage configFilePage;

    @RequestMapping(value = "getConfig",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
    public Result getConfig(){
        log.info("获取配置文件");
        return configFilePage.getConfig();
    }

    @RequestMapping(value = "upDataConfig",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
    public Result upDataConfig(@Validated @RequestBody ConfigFileReq configFileReq){
        log.info("传入修改配置文件 =>" + configFileReq.toString());
        return configFilePage.upDataConfig(configFileReq);
    }

}
